/**
 * @TimeTask.as
 * 
 * @author sodaChen mail:sujun10#21cn.com
 * @version 1.0
 * <br>Copyright (C), 2012 ASFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:ASFrame
 * <br>Date:2012-10-8
 */
package com.asframe.task
{
	/**
	 * 时间任务对象
	 * @author sodaChen
	 * Date:2012-10-8
	 */
	public class TimeTask extends BasicTask
	{
		/** 单次时间片 **/
		protected var time:int;
		/** tmie结束的次数 **/
		protected var timeOver:int;
		/** 当前运行的时间 **/
		protected var currentTime:int;
		/** time运行的次数，-1时表示无数次 **/
		protected var timeCount:int;
		
		public function TimeTask(time:int,timeCount:int = 1)
		{
			this.time = time;
			this.timeCount = timeCount;
		}
		public override function tick():void
		{
			currentTime++;
			if(currentTime >= time)
			{
				currentTime = 0;
				timeEvent();
				if(timeCount != -1)
				{
					timeOver++;
					if(timeOver == timeCount)
					{
						timeOverEvent();
					}
				}
			}
		}
		/**
		 * 单次时间到达调用的函数 
		 * 
		 */		
		protected function timeEvent():void
		{
			
		}
		/**
		 * 总时间到的结束函数 
		 * 
		 */		
		protected function timeOverEvent():void
		{
			
		}
	}
}
